package com.example.rpapp.assembler;

import com.example.config.util.SecurityUtil;
import com.example.rpclient.dto.PrizeAddCmd;
import com.example.rpclient.dto.PrizeUpdateCmd;
import com.example.rpclient.dto.data.PrizeVo;
import com.example.rpdomain.price.PrizeEntity;
import com.example.rpdomain.price.Tnventory;


import java.math.BigDecimal;
import java.time.LocalDateTime;


public class PrizeAssembler {
    public static PrizeEntity toAddEntity(PrizeAddCmd cmd) {
        PrizeEntity prizeEntity = new PrizeEntity();
        prizeEntity.setPrizeName(cmd.getPrizeName());
        prizeEntity.setInventory(new Tnventory(cmd.getInventory()));
        prizeEntity.setMoney(new BigDecimal(cmd.getMoney().toString()));
        prizeEntity.setType(cmd.getType());
        prizeEntity.setCreateTime(LocalDateTime.now());
        prizeEntity.setCreator("大靓仔");
        prizeEntity.setUpdateTime(LocalDateTime.now());
        prizeEntity.setUpdater("大靓仔");

        return prizeEntity;
    }

    public static PrizeVo toPrizeVO(PrizeEntity prizeEntity) {
        PrizeVo prizeVO = new PrizeVo();
        prizeVO.setId(prizeEntity.getId());
        prizeVO.setPrizeName(prizeEntity.getPrizeName());
        prizeVO.setInventory(prizeEntity.getInventory().getInventory());
        prizeVO.setMoney(new BigDecimal(prizeEntity.getMoney().toString()));
        prizeVO.setType(prizeEntity.getType());
        prizeVO.setCreateTime(prizeEntity.getCreateTime());
        prizeVO.setCreator("大靓仔");
        prizeVO.setUpdateTime(prizeEntity.getUpdateTime());
        prizeVO.setUpdater("大靓仔");

        return prizeVO;
    }

    public static PrizeEntity toUpdateEntity(PrizeUpdateCmd cmd) {
        PrizeEntity prizeEntity = new PrizeEntity();
        prizeEntity.setId(cmd.getId());
        prizeEntity.setPrizeName(cmd.getPrizeName());
        prizeEntity.setInventory(new Tnventory(cmd.getInventory()));
        prizeEntity.setMoney(new BigDecimal(cmd.getMoney().toString()));
        prizeEntity.setType(cmd.getType());
        prizeEntity.setUpdateTime(LocalDateTime.now());
        prizeEntity.setUpdater("大靓仔");

        return prizeEntity;
    }
}
